package installer

import (
	"fmt"
	"os"
	"path/filepath"

	"go.uber.org/zap"
)

// verifyInstallation 验证安装结果
// 示例值: installDir="/usr/local/openssh"
func verifyInstallation(installDir string) error {
	zap.L().Info("验证OpenSSH安装结果")

	// 检查安装目录
	if _, err := os.Stat(installDir); err != nil {
		return fmt.Errorf("安装目录不存在: %v", err)
	}

	// 检查关键文件
	keyFiles := []string{
		filepath.Join(installDir, "bin", "ssh"),
		filepath.Join(installDir, "sbin", "sshd"),
		filepath.Join(installDir, "bin", "scp"),
		filepath.Join(installDir, "bin", "sftp"),
	}

	for _, file := range keyFiles {
		if _, err := os.Stat(file); err != nil {
			return fmt.Errorf("关键文件不存在: %s", file)
		}
	}

	zap.L().Info("OpenSSH安装验证通过")
	return nil
}